<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>前言 环境准备 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="实现的小目标实现一个卷积神经网络的训练和计算框架  支持卷积操作（最基础的功能） 支持算子扩充 支持GPU加速  需要熟悉的框架和工具1、Bazel编译工具 2、ProtoBuf库 3、Glog库 4、Gtest库 5、GFlags库 6、BLAS库 7、HDF5库 8、OpenCV库 9、CUDA库 10、Caffe深度学习框架 11、Darknet深度学习框架 12、Jni编程 13、Pybi">
<meta property="og:type" content="article">
<meta property="og:title" content="前言 环境准备">
<meta property="og:url" content="http://cui-rongpei.gitee.io/blog/2022/09/24/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="实现的小目标实现一个卷积神经网络的训练和计算框架  支持卷积操作（最基础的功能） 支持算子扩充 支持GPU加速  需要熟悉的框架和工具1、Bazel编译工具 2、ProtoBuf库 3、Glog库 4、Gtest库 5、GFlags库 6、BLAS库 7、HDF5库 8、OpenCV库 9、CUDA库 10、Caffe深度学习框架 11、Darknet深度学习框架 12、Jni编程 13、Pybi">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2022-09-24T15:05:55.059Z">
<meta property="article:modified_time" content="2022-09-25T07:19:29.923Z">
<meta property="article:author" content="John Doe">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/blog/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/blog/css/style.css">

<meta name="generator" content="Hexo 5.4.2"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/blog/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/blog/">Home</a>
        
          <a class="main-nav-link" href="/blog/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/blog/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://cui-rongpei.gitee.io/blog"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-深度学习/使用C++编写深度学习框架/使用C++编写深度学习框架" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2022/09/24/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/" class="article-date">
  <time datetime="2022-09-24T15:05:55.059Z" itemprop="datePublished">2022-09-24</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/blog/categories/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">深度学习</a>►<a class="article-category-link" href="/blog/categories/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C-%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/">使用C++编写深度学习框架</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      前言 环境准备
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="实现的小目标"><a href="#实现的小目标" class="headerlink" title="实现的小目标"></a>实现的小目标</h1><p>实现一个卷积神经网络的训练和计算框架</p>
<ul>
<li>支持卷积操作（最基础的功能）</li>
<li>支持算子扩充</li>
<li>支持GPU加速</li>
</ul>
<h1 id="需要熟悉的框架和工具"><a href="#需要熟悉的框架和工具" class="headerlink" title="需要熟悉的框架和工具"></a>需要熟悉的框架和工具</h1><p>1、Bazel编译工具</p>
<p>2、ProtoBuf库</p>
<p>3、Glog库</p>
<p>4、Gtest库</p>
<p>5、GFlags库</p>
<p>6、BLAS库</p>
<p>7、HDF5库</p>
<p>8、OpenCV库</p>
<p>9、CUDA库</p>
<p>10、Caffe深度学习框架</p>
<p>11、Darknet深度学习框架</p>
<p>12、Jni编程</p>
<p>13、Pybind11编程</p>
<h3 id="解决虚拟机访问不了github"><a href="#解决虚拟机访问不了github" class="headerlink" title="解决虚拟机访问不了github"></a>解决虚拟机访问不了github</h3><p>在网站<a target="_blank" rel="noopener" href="https://www.ipaddress.com/">https://www.ipaddress.com/</a> 分别搜索</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">github.global.ssl.fastly.net</span><br><span class="line">github.com</span><br></pre></td></tr></table></figure>

<p>得到ip</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">199.232.69.194</span><br><span class="line">140.82.112.4</span><br></pre></td></tr></table></figure>

<p>修改hosts文件：vim /etc/hosts<br>在hosts文件末尾添加两行(对应上面查到的ip)</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">199.232.69.194  github.global.ssl.fastly.net</span><br><span class="line">140.82.112.4  github.com</span><br></pre></td></tr></table></figure>

<p> 完成 再试一下git clone</p>
<h2 id="vscode连接虚拟机"><a href="#vscode连接虚拟机" class="headerlink" title="vscode连接虚拟机"></a>vscode连接虚拟机</h2><p>本来之前配置好的环境，但是不知道怎么出了点问题，废了很久时间还没解决，索性重新安装一遍虚拟机从头记录一下</p>
<h3 id="虚拟机安装ubuntu20-04-（略）"><a href="#虚拟机安装ubuntu20-04-（略）" class="headerlink" title="虚拟机安装ubuntu20.04 （略）"></a>虚拟机安装ubuntu20.04 （略）</h3><h3 id="ubuntun-换源"><a href="#ubuntun-换源" class="headerlink" title="ubuntun 换源"></a>ubuntun 换源</h3><p>vi /etc/apt/sources.list 粘贴如下内容</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse</span><br><span class="line">deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse</span><br><span class="line"></span><br><span class="line">deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse</span><br><span class="line">deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse</span><br><span class="line"></span><br><span class="line">deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse</span><br><span class="line">deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse</span><br><span class="line"></span><br><span class="line"># deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse</span><br><span class="line"># deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse</span><br><span class="line"></span><br><span class="line">deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse</span><br><span class="line">deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>换源后记得更新包</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt update</span><br></pre></td></tr></table></figure>

<p>安装必要的软件</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install net-tools</span><br><span class="line">sudo apt install vim</span><br><span class="line">sudo apt install g++</span><br></pre></td></tr></table></figure>



<h3 id="安装openssh-server"><a href="#安装openssh-server" class="headerlink" title="安装openssh-server"></a>安装openssh-server</h3><p>打开终端安装openssh-server软件包：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo apt update  # 更新包</span><br><span class="line">sudo apt install openssh-server  # 安装openssh-server</span><br></pre></td></tr></table></figure>

<p>安装完成后，ssh服务默认启动了，可以通过下面的命令检查服务运行状态：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo systemctl status ssh</span><br></pre></td></tr></table></figure>

<p>注意“active”是“running”，说明ssh服务启动了</p>
<h3 id="防火墙开启ssh端口"><a href="#防火墙开启ssh端口" class="headerlink" title="防火墙开启ssh端口"></a>防火墙开启ssh端口</h3><p>Ubuntu 默认使用 ufw 防火墙配置工具，如果启用了防火墙，需要让防火墙开启ssh端口：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo ufw allow ssh</span><br></pre></td></tr></table></figure>

<h3 id="配置允许远程访问"><a href="#配置允许远程访问" class="headerlink" title="配置允许远程访问"></a>配置允许远程访问</h3><p>使用sudo权限，编辑ssh的配置文件。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo vim /etc/ssh/sshd_config</span><br></pre></td></tr></table></figure>

<p>将#PermitRootLogin prohibit-password中prohibit-password去掉改为yes，并把PermitRootLogin yes之前的#去掉：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PermitRootLogin yes</span><br></pre></td></tr></table></figure>

<p>重启ssh服务</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service sshd restart</span><br></pre></td></tr></table></figure>

<h3 id="vscode连接ssh服务"><a href="#vscode连接ssh服务" class="headerlink" title="vscode连接ssh服务"></a>vscode连接ssh服务</h3><p>在虚拟机中查看ip地址</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ifconfig</span><br></pre></td></tr></table></figure>

<p>使用ens33的inet 比如我的是192.168.204.128</p>
<p>然后在vscode中,hunter是我虚拟机的用户名</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ssh hunter@192.168.204.128</span><br></pre></td></tr></table></figure>

<p>ok，连接上了完美。</p>
<p>之前一直没弄上是因为虚拟机不知道怎么回事上不去网…</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://cui-rongpei.gitee.io/blog/2022/09/24/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/" data-id="cl8h5o79c000isot916lhgwy8" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/blog/2022/09/25/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/bazel%E5%85%A5%E9%97%A8/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          bazel入门
        
      </div>
    </a>
  
  
    <a href="/blog/2022/09/24/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/%E8%B6%85%E7%AE%97%E5%B9%B3%E5%8F%B0%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">超算平台深度学习环境搭建</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/blog/categories/C-C/">C/C++</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">深度学习</a><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%B8%9C%E6%96%B9%E8%80%80%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">东方耀机器学习</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C-%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/">使用C++编写深度学习框架</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/">深度学习环境搭建</a></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E8%AE%BA%E6%96%87%E7%AC%94%E8%AE%B0/">论文笔记</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E8%BF%91%E6%9C%9F%E8%A7%84%E5%88%92/">近期规划</a></li></ul>
    </div>
  </div>


  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2022/09/">September 2022</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/blog/2022/09/25/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/gflags%E5%85%A5%E9%97%A8/">gflags入门</a>
          </li>
        
          <li>
            <a href="/blog/2022/09/25/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/glog%E5%85%A5%E9%97%A8/">glog入门</a>
          </li>
        
          <li>
            <a href="/blog/2022/09/25/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/bazel%E5%85%A5%E9%97%A8/">bazel入门</a>
          </li>
        
          <li>
            <a href="/blog/2022/09/24/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/%E4%BD%BF%E7%94%A8C++%E7%BC%96%E5%86%99%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A1%86%E6%9E%B6/">前言 环境准备</a>
          </li>
        
          <li>
            <a href="/blog/2022/09/24/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/%E8%B6%85%E7%AE%97%E5%B9%B3%E5%8F%B0%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/">超算平台深度学习环境搭建</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2022 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/blog/" class="mobile-nav-link">Home</a>
  
    <a href="/blog/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/blog/fancybox/jquery.fancybox.css">

  
<script src="/blog/fancybox/jquery.fancybox.pack.js"></script>




<script src="/blog/js/script.js"></script>




  </div>
</body>
</html>